﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Windows.Forms;

namespace ProStore
{
    class DAO
    {
        private static string ServerIP = Panel.ServerIP;
        private static string User = Panel.User;
        private static string Password = Panel.Password;
        private static string Database = "ProStore";

        private static string sConn = "Data Source=" + ServerIP + ";" +
                        "Database=" + Database + "; " +
                        "User Id=" + User + "; " +
                        "Password=" + Password + ";";
        
        SqlConnection connection = new SqlConnection(sConn);

        public bool Conectar()
        {
            try
            {
                connection.Open();
                return true;
            }catch(Exception e)
            {
                MessageBox.Show(e.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
        }

        public bool Desconectar()
        {
            connection.Close();
            return true;
        }
    }
}
